/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.ui;

//import java.io.IOException;
//import nominalitzacions.domain.LanguageDomainController;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import nominalitzacions.domain.LanguageDomainController;
import nominalitzacions.domain.PasswordDomainController;
import nominalitzacions.domain.UrlDomainController;

/**
 *
 * @author daniel.camacho.rodriguez
 */
public class FirstRunViewController {

    private PrincipalViewController PVC;
    
    private PasswordDomainController PDC;
    private FirstRunView FRV = null;

    private LanguageDomainController LDC;
    private UrlDomainController UDC;

    public FirstRunViewController() throws IOException{
        try {
            PVC = new PrincipalViewController();
        } catch (FileNotFoundException ex) {

        }
        UDC = new UrlDomainController();
        if (FRV == null) FRV = new FirstRunView(this);    
        try {
            LDC = new LanguageDomainController();
            PDC = new PasswordDomainController();
        } catch (IOException ex) {
            
        }
    }

    public void setVisible(){
        FRV.setVisible(true);
    }

    public void passIs(String pass) throws IOException {
        PDC.changePassTo(pass);
    }

    public void previous(int vista){
        FRV.changeTo(vista - 1);
    }

    public void next(int vista){
        if(!(new File(UDC.getRoot()).exists())) UDC.createFolders();
        FRV.changeTo(vista + 1);
    }
    
    public void closeFirstRun(){
        FRV.setInvisible();
    }

    public void setLanguage(String lang, String inf, String irr, String noun, String corp) throws IOException {
        // Falta implementar
        System.out.println(lang);
        System.out.println(inf);
        System.out.println(irr);
        System.out.println(noun);
        System.out.println(corp);

        LDC.addLanguage(lang, inf, irr, noun, corp);
    }

    public boolean isFirst(){
        return UDC.isFirst();
    }

    public void showPrincipalView(){
        PVC.setVisible();
    }

}
